﻿using System;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using Lib.Utilities;
using System.Data;
using Lib.Helper;

[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class wht_nsd
{


    // To use HTTP GET, add [WebGet] attribute. (Default ResponseFormat is WebMessageFormat.Json)
    // To create an operation that returns XML,
    //     add [WebGet(ResponseFormat=WebMessageFormat.Xml)],
    //     and include the following line in the operation body:
    //         WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
    [OperationContract]

    public string Fs_LOGIN(string b_user, string b_pass)
    {
        try
        {
            DataTable b_dt = ht.P_LOGIN(b_user, b_pass);
            if (!LibTable.isNullOrEmtyTable(b_dt))
            {
                string modun = "", cn = "";
                foreach (DataRow dr in b_dt.Rows)
                {
                    string b_modun = LibConvert.ObjectToString(dr["modun"]);
                    if (modun.IndexOf(b_modun) < 0)
                        modun = modun + b_modun + ";";
                    cn = cn + LibConvert.ObjectToString(dr["id_cn"]) + ";";
                }
                if (!string.IsNullOrEmpty(modun))
                    modun = modun.Substring(0, modun.Length - 1);
                if (!string.IsNullOrEmpty(cn))
                    cn = cn.Substring(0, cn.Length - 1);
                DataRow _row = b_dt.Rows[0];
                SessionHelper _nsd = new SessionHelper();
                _nsd.cn = cn;
                _nsd.modun = modun;
                _nsd.nsd = LibConvert.ObjectToString(_row["id_nsd"]);
                _nsd.ten = LibConvert.ObjectToString(_row["ten"]);
                _nsd.id_nsd = LibConvert.ObjectToString(_row["id_ns"]);
                _nsd.dbo = "dbo";
                SessionHelper.RemoveSession("nsd");
                System.Web.HttpContext.Current.Session["nsd"] = _nsd;
            }
            return "";
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }
    [OperationContract]
    public string Fs_MENU()
    {
        try
        {
            StringBuilder _menu = new StringBuilder();
            SessionHelper _nsd = new SessionHelper();
            string modun = _nsd.modun, cn = _nsd.cn;

            //NÔNG DÂN
            _menu.Append(" <h3>Quản trị hệ thống </h3>  <div style=\"padding:0px !important;\" >");
            _menu.Append(" <table class=\"table-select\"> ");
            if (modun.IndexOf("QUYEN") >= 0)
            {
                if (cn.IndexOf("NSD") >= 0)
                {
                    _menu.Append(" <tr> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Thêm người sử dụng</a> </td></tr> ");
                }
                if (cn.IndexOf("PQ") >= 0)
                {
                    _menu.Append(" <tr> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Phân quyền sử dụng</a> </td></tr> ");
                }
                if (cn.IndexOf("PQ") >= 0)
                {
                    _menu.Append(" <tr> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Sao lưu - lưu trữ dữ liệu</a> </td></tr> ");
                }
            }
            _menu.Append(" <tr  id=\"thoat\" onclick=\"P_MENU_CHON('THOAT');\"> <td> ");
            _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Thoát</a> </td></tr> ");
            _menu.Append("</table>");
            _menu.Append("</div>");
            
            if (modun.IndexOf("DM") >= 0)
            {
                _menu.Append(" <h3> Danh mục hệ thống </h3>  <div style=\"padding:0px !important;\" >");
                _menu.Append(" <table class=\"table-select\"> ");
                if (cn.IndexOf("TTCHUNG") >= 0)
                {
                    _menu.Append(" <tr  id=\"truong\"> <td> ");
                    _menu.Append(" <a  onclick=\"P_MENU_CHON('TRUONG');\" style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Thông tin chung </a> </td></tr> ");
                }
                if (cn.IndexOf("TINH") >= 0)
                {
                    _menu.Append(" <tr id=\"tinh\" onclick=\"P_MENU_CHON('TINH');\"> <td> ");
                    _menu.Append(" <a   style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Tỉnh </a> </td></tr> ");
                }
                if (cn.IndexOf("HUYEN") >= 0)
                {
                    _menu.Append(" <tr id=\"huyen\" onclick=\"P_MENU_CHON('HUYEN');\"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Huyện </a> </td></tr> ");
                }
                if (cn.IndexOf("XA") >= 0)
                {
                    _menu.Append(" <tr id=\"xa\" onclick=\"P_MENU_CHON('XA'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Xã/Phường </a> </td></tr> ");
                }
                if (cn.IndexOf("DANTOC") >= 0)
                {
                    _menu.Append(" <tr id=\"dantoc\" onclick=\"P_MENU_CHON('DANTOC'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Dân tộc </a> </td></tr> ");
                }
                if (cn.IndexOf("DOITUONG") >= 0)
                {
                    _menu.Append(" <tr id=\"dtuong\" onclick=\"P_MENU_CHON('DTUONG'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Đối tượng </a> </td></tr> ");
                }
                if (cn.IndexOf("PHONG") >= 0)
                {
                    _menu.Append(" <tr> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Phòng ban </a> </td></tr> ");
                }

                _menu.Append("</table>");
                _menu.Append("</div>");
            }
            if (modun.IndexOf("DT") >= 0)
            {
                _menu.Append(" <h3>Quản lý Đào tạo </h3>  <div style=\"padding:0px !important;\" >");
                _menu.Append(" <table class=\"table-select\"> ");
                if (cn.IndexOf("NAM") >= 0)
                {
                    _menu.Append(" <tr id=\"nam\" onclick=\"P_MENU_CHON('NAM'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Năm học </a> </td></tr> ");
                }
                if (cn.IndexOf("HT_DT") >= 0)
                {
                    _menu.Append(" <tr id=\"htdt\" onclick=\"P_MENU_CHON('HTDT'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Hệ đào tạo</a> </td></tr> ");
                }
                if (cn.IndexOf("KHOA") >= 0)
                {
                    _menu.Append(" <tr id=\"khoa\" onclick=\"P_MENU_CHON('KHOA'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Khóa học </a> </td></tr> ");
                }
                if (cn.IndexOf("LOP") >= 0)
                {
                    _menu.Append(" <tr id=\"lop\" onclick=\"P_MENU_CHON('LOP'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Lớp học </a> </td></tr> ");
                }
                if (cn.IndexOf("BOMON") >= 0)
                {
                    _menu.Append(" <tr id=\"bomon\" onclick=\"P_MENU_CHON('BOMON'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Bộ môn </a> </td></tr> ");
                }
                if (cn.IndexOf("MON") >= 0)
                {
                    _menu.Append(" <tr id=\"mon\" onclick=\"P_MENU_CHON('MON'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Môn học</a> </td></tr> ");
                }
                if (cn.IndexOf("DAUNAM") >= 0)
                {
                    _menu.Append(" <tr id=\"daunam\" onclick=\"P_MENU_CHON('DAUNAM'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Đầu năm</a> </td></tr> ");
                }
                if (cn.IndexOf("MON_TN") >= 0)
                {
                    _menu.Append(" <tr id=\"mon_tn\" onclick=\"P_MENU_CHON('MON_TN'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Môn tốt nghiệp</a> </td></tr> ");
                }
                //CT
                if (cn.IndexOf("GIANGDAY") >= 0)
                {
                    _menu.Append(" <tr id=\"giangday\" onclick=\"P_MENU_CHON('GIANGDAY'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Phân công giảng dậy</a> </td></tr> ");
                }
                if (cn.IndexOf("TKB") >= 0)
                {
                    _menu.Append(" <tr id=\"tkb\" onclick=\"P_MENU_CHON('TKB'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Thời khóa biểu</a> </td></tr> ");
                }
                if (cn.IndexOf("DKLICH_HOC") >= 0)
                {
                    _menu.Append(" <tr id=\"dky_lich_hoc\" onclick=\"P_MENU_CHON('DKY_LICH_HOC'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Đăng ký lịch học</a> </td></tr> ");
                }
                if (cn.IndexOf("NHAPDIEM") >= 0)
                {
                    _menu.Append(" <tr id=\"nhapdiem\" onclick=\"P_MENU_CHON('NHAPDIEM'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Nhập điểm</a> </td></tr> ");
                }
                if (cn.IndexOf("KHOASO") >= 0)
                {
                    _menu.Append(" <tr id=\"khoaso\" onclick=\"P_MENU_CHON('KHOASO'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Khóa sổ</a> </td></tr> ");
                }
                if (cn.IndexOf("DIEM_CK") >= 0)
                {
                    _menu.Append(" <tr id=\"diem_ck\" onclick=\"P_MENU_CHON('DIEM_CK'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" /> Điểm cuối kỳ</a> </td></tr> ");
                }
                if (cn.IndexOf("DIEM_CN") >= 0)
                {
                    _menu.Append(" <tr id=\"diem_cn\" onclick=\"P_MENU_CHON('DIEM_CN'); \"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" />Phiếu báo điểm-Phân loại</a> </td></tr> ");
                }
                _menu.Append("</table>");
                _menu.Append("</div>");
            }
            if (modun.IndexOf("DT") >= 0)
            {
                _menu.Append(" <h3>Quản lý Kí túc xá </h3>  <div style=\"padding:0px !important;\" >");
                _menu.Append(" <table class=\"table-select\"> ");
                if (cn.IndexOf("NHAKTX") >= 0)
                {
                    _menu.Append(" <tr id=\"nhaktx\" onclick=\"P_MENU_CHON('NHAKTX');\"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" />Nhà</a> </td></tr> ");
                }
                if (cn.IndexOf("PHONGKTX") >= 0)
                {
                    _menu.Append(" <tr id=\"phongktx\" onclick=\"P_MENU_CHON('PHONGKTX');\"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" />Phòng</a> </td></tr> ");
                }
                if (cn.IndexOf("DANGKYKTX") >= 0)
                {
                    _menu.Append(" <tr id=\"dangkyktx\" onclick=\"P_MENU_CHON('DANGKYKTX');\"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" />Đăng ký,xếp phòng</a> </td></tr> ");
                }
                _menu.Append("</table>");
                _menu.Append("</div>");
            }

            if (modun.IndexOf("NS") >= 0)
            {
                _menu.Append(" <h3>Quản lý Nhân sự </h3>  <div style=\"padding:0px !important;\" >");
                _menu.Append(" <table class=\"table-select\"> ");
                if (cn.IndexOf("NHANSU") >= 0)
                {
                    _menu.Append(" <tr id=\"nhansuexcel\" onclick=\"P_MENU_CHON('NHANSUEXEL');\"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" />Import Excel</a> </td></tr> ");
                }
                _menu.Append("</table>");
                _menu.Append("</div>");
            }
            if (modun.IndexOf("SV") >= 0)
            {
                _menu.Append(" <h3>Quản lý Học sinh - Sinh viên </h3>  <div style=\"padding:0px !important;\" >");
                _menu.Append(" <table class=\"table-select\"> ");
                if (cn.IndexOf("DS_SV") >= 0)
                {
                    _menu.Append(" <tr id=\"sinhvien\" onclick=\"P_MENU_CHON('SINHVIEN');\"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" />Hồ sơ sinh viên</a> </td></tr> ");
                }
                if (cn.IndexOf("DS_SV") >= 0)
                {
                    _menu.Append(" <tr id=\"khen_thuong\" onclick=\"P_MENU_CHON('KHEN_THUONG');\"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" />Khen thưởng, kỷ luật</a> </td></tr> ");
                }
                if (cn.IndexOf("DS_SV") >= 0)
                {
                    _menu.Append(" <tr> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" />Xuất hồ sơ theo mẫu </a> </td></tr> ");
                }
                if (cn.IndexOf("SINHVIEN") >= 0)
                {
                    _menu.Append(" <tr id=\"sinhvienexcel\" onclick=\"P_MENU_CHON('SINHVIENEXCEL');\"> <td> ");
                    _menu.Append(" <a  style=\"text-decoration: none; margin: 30px; color: black;\"><image src=\"../../Images/icon/bullet_icon.jpg\" />Import Excel</a> </td></tr> ");
                }
                _menu.Append("</table>");
                _menu.Append("</div>");
            }
            return _menu.ToString();
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }
    [OperationContract]

    public string FDM_TT_TRUONG_NH(object[] dl)
    {
        try
        {
            string[] a_ten = LibConvert.ArrObjectToArrString((object[])dl[0]);
            object[] a_gtri = (object[])dl[1];
            DataTable b_dt = LibTable.CreateTable(a_ten, a_gtri);
            ht.PTT_TRUONG_NH(b_dt);
            return LibTable.TableToJson(ht.Fdt_tt_truong_lke());
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }

    [OperationContract]

    public string FDM_TT_TRUONG_CT(string ma_truong)
    {
        try
        {
            DataTable b_dt = ht.Fdt_TT_TRUONG_CT(ma_truong);
            return LibTable.TableToJson(b_dt);
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }
    [OperationContract]

    public string FDM_TT_TRUONG_XOA(string ma_truong)
    {
        try
        {
            ht.PTT_TRUONG_XOA(ma_truong);
            return LibTable.TableToJson(ht.Fdt_tt_truong_lke()); ;
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }

    //TINH
    [OperationContract]

    public string FDM_TINH_NH(string ma, string ten)
    {
        try
        {
            SessionHelper _nsd = SessionHelper.GetSessionUser();
            ht.FDM_TINH_NH(_nsd.nsd, ma, ten);
            return LibTable.TableToJson(ht.FDM_TINH_LKE());
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }
    [OperationContract]

    public string FDM_TINH_XOA(string ma)
    {
        try
        {
            SessionHelper _nsd = SessionHelper.GetSessionUser();
            ht.FDM_TINH_XOA(_nsd.nsd, ma);
            return LibTable.TableToJson(ht.FDM_TINH_LKE());
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }

    //HUYEN
    [OperationContract]

    public string FDM_HUYEN_LKE(string tinh_id)
    {
        try
        {
            DataTable b_dt = ht.FDM_HUYEN_LKE(tinh_id);
            return LibTable.TableToJson(b_dt);
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }
    [OperationContract]

    public string FDM_HUYEN_NH(string tinh_id, string ma, string ten)
    {
        try
        {
            string so_id = ht.FDM_HUYEN_NH(tinh_id, ma, ten);
            return so_id + "#" + LibTable.TableToJson(ht.FDM_HUYEN_LKE(tinh_id));
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }

    [OperationContract]

    public string FDM_HUYEN_XOA(string tinh_id, string ma)
    {
        try
        {
            ht.FDM_HUYEN_XOA(tinh_id, ma);
            return LibTable.TableToJson(ht.FDM_HUYEN_LKE(tinh_id));
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }
    //XA
    [OperationContract]

    public string FDM_XA_LKE(string huyenid)
    {
        try
        {
            DataTable b_dt = ht.FDM_XA_LKE(huyenid);
            return LibTable.TableToJson(b_dt);
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }
    [OperationContract]

    public string FDM_XA_NH(string idtinh, string huyen, string ma, string ten)
    {
        try
        {
            string id = ht.FDM_XA_NH(idtinh, huyen, ma, ten);
            return id + "#" + LibTable.TableToJson(ht.FDM_XA_LKE(huyen));
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }

    [OperationContract]

    public string FDM_XA_XOA(string HUYEN, string ma)
    {
        try
        {
            ht.FDM_XA_XOA(ma);
            return LibTable.TableToJson(ht.FDM_XA_LKE(HUYEN));
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }

    //DAN TỘC
    [OperationContract]

    public string FDM_DANTOC_LKE()
    {
        try
        {
            DataTable b_dt = ht.FDM_DANTOC_LKE();
            return LibTable.TableToJson(b_dt);
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }
    [OperationContract]

    public string FDM_DANTOC_NH(string ma, string ten)
    {
        try
        {
            string id = ht.FDM_DANTOC_NH(LibConvert.ObjectToDouble(ma), ten);
            return id + "#" + LibTable.TableToJson(ht.FDM_DANTOC_LKE());
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }

    [OperationContract]

    public string FDM_DANTOC_XOA(string ma)
    {
        try
        {
            ht.FDM_DANTOC_XOA(LibConvert.ObjectToDouble(ma));
            return LibTable.TableToJson(ht.FDM_DANTOC_LKE());
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }

    //DOITUONG
    [OperationContract]

    public string FDM_DOITUONG_LKE()
    {
        try
        {
            DataTable b_dt = ht.FDM_DOITUONG_LKE();
            return LibTable.TableToJson(b_dt);
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }
    [OperationContract]

    public string FDM_DOITUONG_NH(string ma, string ten, string hso)
    {
        try
        {
            string id = ht.FDM_DOITUONG_NH(LibConvert.ObjectToDouble(ma), ten, LibConvert.ObjectToFloat(hso));
            return id + "#" + LibTable.TableToJson(ht.FDM_DOITUONG_LKE());
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }

    [OperationContract]

    public string FDM_DOITUONG_XOA(string ma)
    {
        try
        {
            ht.FDM_DOITUONG_XOA(LibConvert.ObjectToDouble(ma));
            return LibTable.TableToJson(ht.FDM_DOITUONG_LKE());
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }

    //nha - kí túc xá
    [OperationContract]

    public string FKTX_NHA_LKE()
    {
        try
        {
            DataTable b_dt = ht.FKTX_NHA_LKE();
            return LibTable.TableToJson(b_dt);
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }
    [OperationContract]

    public string FKTX_NHA_NH(string ma, string ten)
    {
        try
        {
            string id = ht.FKTX_NHA_NH(LibConvert.ObjectToDouble(ma), ten);
            return id + "#" + LibTable.TableToJson(ht.FKTX_NHA_LKE());
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }

    [OperationContract]

    public string FKTX_NHA_XOA(string ma)
    {
        try
        {
            ht.FKTX_NHA_XOA(LibConvert.ObjectToDouble(ma));
            return LibTable.TableToJson(ht.FKTX_NHA_LKE());
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }

    //phong
    [OperationContract]

    public string FKTX_PHONG_LKE(string nha_id)
    {
        try
        {
            DataTable b_dt = ht.FKTX_PHONG_LKE(nha_id);
            return LibTable.TableToJson(b_dt);
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }
    [OperationContract]

    public string FKTX_PHONG_NH(string nha_id, string ma, string ten, string giuong)
    {
        try
        {
            string so_id = ht.FKTX_PHONG_NH(nha_id, ma, ten, giuong);
            return so_id + "#" + LibTable.TableToJson(ht.FKTX_PHONG_LKE(nha_id));
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }

    [OperationContract]

    public string FKTX_PHONG_XOA(string nha_id, double ma)
    {
        try
        {
            ht.FKTX_PHONG_XOA(ma);
            return LibTable.TableToJson(ht.FKTX_PHONG_LKE(nha_id));
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }
    //Dang ky phong

    [OperationContract]

    public string FKTX_DANGKY_LKE(string phong_id)
    {
        try
        {
            DataTable b_dt = ht.FKTX_DANGKY_LKE(phong_id);
            return LibTable.TableToJson(b_dt);
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }

    [OperationContract]

    public string FDT_HTDT_LKE(string bac_id)
    {
        try
        {
            DataTable b_dt = ht.FDT_HTDT_LKE(bac_id);
            return LibTable.TableToJson(b_dt);
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }

    [OperationContract]

    public string FDT_NGANH_LKE(string htdt_id)
    {
        try
        {
            DataTable b_dt = ht.FDT_NGANH_LKE(htdt_id);
            return LibTable.TableToJson(b_dt);
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }
    [OperationContract]

    public string FDT_CHONCAUHINH_LKE(string bac_id, string htdt_id, string nganh_id)
    {
        try
        {
            System.Web.HttpContext.Current.Session["bacdt"] = bac_id;
            System.Web.HttpContext.Current.Session["hedt"] = htdt_id;
            System.Web.HttpContext.Current.Session["nganhdt"] = nganh_id;
            return "";
        }
        catch (Exception e)
        {
            return LibForm.GetError(e.Message);
        }
    }

}
